package net.maku.custom.biza.controller.followup;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import javax.validation.Valid;
import lombok.AllArgsConstructor;
import net.maku.custom.biza.controller.followup.query.FollowUpDetailsQuery;
import net.maku.custom.biza.controller.followup.vo.FollowUpDetailsVO;
import net.maku.custom.biza.service.followup.FollowUpDetailsService;
import net.maku.framework.common.page.PageResult;
import net.maku.framework.common.utils.Result;
import org.springframework.web.bind.annotation.*;

/**
* 跟进明细
*
* @author NULL
* @since 1.0.0 2022-07-11
*/
@RestController
@RequestMapping("/followupDetails")
@Tag(name="跟进明细")
@AllArgsConstructor
public class FollowUpDetailsController {
    private final FollowUpDetailsService followUpDetailsService;

    @GetMapping("/page")
    @Operation(summary = "分页")
    public Result<PageResult<FollowUpDetailsVO>> page(@Valid FollowUpDetailsQuery query){
        PageResult<FollowUpDetailsVO> page = followUpDetailsService.page(query);

        return Result.ok(page);
    }

    @GetMapping("/{id}")
    @Operation(summary = "信息")
    public Result<FollowUpDetailsVO> get(@PathVariable("id") Long id){
        FollowUpDetailsVO followUpDetailsVO = followUpDetailsService.selectRelById(id);

        return Result.ok(followUpDetailsVO);
    }

    @PostMapping("/save")
    @Operation(summary = "保存")
    public Result<String> save(@RequestBody FollowUpDetailsVO vo){
        followUpDetailsService.save(vo);

        return Result.ok();
    }

    @PostMapping("/update")
    @Operation(summary = "修改")
    public Result<String> update(@RequestBody @Valid FollowUpDetailsVO vo){
        followUpDetailsService.update(vo);

        return Result.ok();
    }

    @PostMapping("/delete")
    @Operation(summary = "删除")
    public Result<String> delete(@RequestBody List<Long> idList){
        followUpDetailsService.delete(idList);

        return Result.ok();
    }
}